const http = require('http');
const routes = require('./处理文件后缀名/routes')

http.createServer((req, res)=>{
    //创建静态web服务
    if(routes.static(req,res,'static')){
        return;
    }
    
    //路由
    let pathname = req.url;

    if(pathname == '/login'){
        res.writeHead(200, { 'Content-Type':'text/html;charset="utf-8"' });
        res.end('login');
    }else if(pathname == '/register'){
        res.writeHead(200, { 'Content-Type':'text/html;charset="utf-8"' });
        res.end('执行注册');
    }else if(pathname == '/admin'){
        res.writeHead(200, { 'Content-Type':'text/html;charset="utf-8"' });
        res.end('处理后的业务逻辑');
    }else {
        res.writeHead(200, { 'Content-Type':'text/html;charset="utf-8"' });
        res.end('页面不存在');
    }
    
}).listen(8081);
console.log("Server runing at http://127.0.0.1:8081/");
